package com.istock.servicesample.controller;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.istock.base.common.api.model.ApiBaseResponse;
import com.istock.base.common.api.model.PageInfo;
import com.istock.sampleService.model.SenvonInfoShowListRequest;
import com.istock.sampleService.model.SenvonInfoVO;
import com.istock.sampleservice.api.SenvonInfoFeignClient;

@RequestMapping("senvonInfoPost")
@RestController
public class SenvonInfoPostController {

	@Autowired
	private SenvonInfoFeignClient client;
	
	@RequestMapping(value="showList",method=RequestMethod.POST)
	public ApiBaseResponse<PageInfo<SenvonInfoVO>> showList(String name , PageInfo pageInfo) {
		SenvonInfoShowListRequest request = new SenvonInfoShowListRequest();
		request.setXxName("senvon");
		
		if(StringUtils.isNotBlank(name)) {
			request.setName(name);
		}
		
		if(pageInfo != null) {
			request.setPageNo(pageInfo.getCurrent());
			request.setPageSize(pageInfo.getLimit());
		}
		
		return client.showList(request);
	}
	
	@RequestMapping(value="add",method=RequestMethod.POST)
	public ApiBaseResponse<Void> add(String name){
		SenvonInfoShowListRequest request = new SenvonInfoShowListRequest();
		request.setName(name);
		return client.add(request);
	}
	
	@RequestMapping(value="exception",method=RequestMethod.POST)
	public ApiBaseResponse<Void> exception(String name){
		return client.exception(name);
	}
}
